<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>history对象</title>
    <script>
        window.onload=function () {
            document.getElementById("div").innerText= history.length;
        }
    </script>
</head>
<body>

<button onclick="history.back()">返回上一级浏览页面</button>
<button onclick="history.forward()">前进进入下一级页面</button>
<!--go参数可控制前进后退的页数-->
<button onclick="history.go(0)">刷新</button>
<button onclick="history.go(1)">前进</button>
<button onclick="history.go(-1)">后退</button>
<button onclick=" history.length" >获取长度</button>
<div id="div"></div>
</body>
</html>